<?php

namespace app\admin\controller\xmwms;

use app\common\controller\Backend;

/**
 * 平台管理
 */
class Platform extends Backend
{
    /**
     * Platform模型对象
     * @var object
     * @phpstan-var \app\admin\model\xmwms\Platform
     */
    protected object $model;

    protected array|string $preExcludeFields = ['id', 'create_time', 'update_time'];

    protected string|array $quickSearchField = ['id'];

    public function initialize(): void
    {
        parent::initialize();
        $this->model = new \app\admin\model\xmwms\Platform;
    }


    /**
     * 若需重写查看、编辑、删除等方法，请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
     */


     /**
      * 查看
      * @throws Throwable
      */
     public function index(): void
     {
          if ($this->request->param('select')) {
               $this->select();
          }

          list($where, $alias, $limit, $order) = $this->queryBuilder();
          $res = $this->model
               ->field($this->indexField)
               ->withJoin($this->withJoinTable, $this->withJoinType)
               ->alias($alias)
               ->where($where)
               ->order('id asc')
               ->paginate($limit);

          $this->success('', [
               'list'   => $res->items(),
               'total'  => $res->total(),
               'remark' => get_route_remark(),
          ]);
     }
}
